home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / uemacs / part5 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  26.7 KB

  1. From: genrad!decvax!minow (Martin Minow)
  2. Subject: MicroEmacs (Part 5 of 6)
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 72
  7. Submitted by: decvax!minow (Martin Minow)
  8.  
  9. #! /bin/sh
  10. # This is a shell archive, meaning:
  11. # 1. Remove everything above the #! /bin/sh line.
  12. # 2. Save the resulting text in a file.
  13. # 3. Execute the file with /bin/sh (not csh) to create the files:
  14. #    tty
  15. # This archive created: Sun Apr 13 11:18:12 1986
  16. export PATH; PATH=/bin:$PATH
  17. if test ! -d 'tty'
  18. then
  19.     echo shar: creating directory "'tty'"
  20.     mkdir 'tty'
  21. fi
  22. if test ! -d 'tty/ansi'
  23. then
  24.     echo shar: creating directory "'tty/ansi'"
  25.     mkdir 'tty/ansi'
  26. fi
  27. echo shar: extracting "'tty/ansi/tty.c'" '(7315 characters)'
  28. if test -f 'tty/ansi/tty.c'
  29. then
  30.     echo shar: will not over-write existing file "'tty/ansi/tty.c'"
  31. else
  32. cat << \SHAR_EOF > 'tty/ansi/tty.c'
  33. /*
  34.  * Name:    MicroEMACS
  35.  *        Digital ANSI terminal display
  36.  * Version:    29
  37.  * Last edit:    10-Feb-86
  38.  * By:        rex::conroy
  39.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  40.  *
  41.  * The SCALD display is just an ANSI display, with
  42.  * some special hacks to kludge around the bugs, and
  43.  * to make it a bit more friendly. The support is
  44.  * unquestionably non-optimal. The costs are wrong; in
  45.  * fact, display should be fixed up to understand non
  46.  * linear cost devices like the SCALD. The BackIndex
  47.  * sequence used in the insert line is defective in
  48.  * the display firmware, so we set the cost high to
  49.  * discourage its use. Perhaps the cost should be
  50.  * set to infinity!
  51.  */
  52. #include    "def.h"
  53.  
  54. #define    SCALD    0            /* Buggy display.        */
  55.  
  56. #define    BEL    0x07            /* BEL character.        */
  57. #define    ESC    0x1B            /* ESC character.        */
  58. #define    LF    0x0A            /* Line feed.            */
  59.  
  60. extern    int    ttrow;
  61. extern    int    ttcol;
  62. extern    int    tttop;
  63. extern    int    ttbot;
  64. extern    int    tthue;
  65.  
  66. #if    SCALD
  67.  
  68. int    tceeol    =    3;        /* Costs, SCALDstation.        */
  69. int    tcinsl    =     100;
  70. int    tcdell    =    100;
  71.  
  72. #else
  73.  
  74. int    tceeol    =    3;        /* Costs, ANSI display.        */
  75. int    tcinsl    =     17;
  76. int    tcdell    =    16;
  77.  
  78. #endif
  79.  
  80. /*
  81.  * Initialize the terminal when the editor
  82.  * gets started up. This is a no-op on the ANSI
  83.  * display. On the SCALD display, it turns off the
  84.  * half-screen scroll, because this appears to really
  85.  * confuse the scrolling region firmware in the
  86.  * display.
  87.  */
  88. ttinit()
  89. {
  90. #if    SCALD
  91.     ttputc(ESC);            /* Cancel jump interval.    */
  92.     ttputc('[');
  93.     asciiparm(1);
  94.     ttputc('j');
  95. #endif
  96. }
  97.  
  98. /*
  99.  * Clean up the terminal, in anticipation of
  100.  * a return to the command interpreter. This is a no-op
  101.  * on the ANSI display. On the SCALD display, it sets the
  102.  * window back to half screen scrolling. Perhaps it should
  103.  * query the display for the increment, and put it
  104.  * back to what it was.
  105.  */
  106. tttidy()
  107. {
  108. #if    SCALD
  109.     ttputc(ESC);            /* Half screen.            */
  110.     ttputc('[');
  111.     asciiparm(nrow/2);
  112.     ttputc('j');
  113. #endif
  114. }
  115.  
  116. /*
  117.  * Move the cursor to the specified
  118.  * origin 0 row and column position. Try to
  119.  * optimize out extra moves; redisplay may
  120.  * have left the cursor in the right
  121.  * location last time!
  122.  */
  123. ttmove(row, col)
  124. {
  125.     if (ttrow!=row || ttcol!=col) {
  126.         ttputc(ESC);
  127.         ttputc('[');
  128.         asciiparm(row+1);
  129.         ttputc(';');
  130.         asciiparm(col+1);
  131.         ttputc('H');
  132.         ttrow = row;
  133.         ttcol = col;
  134.     }
  135. }
  136.  
  137. /*
  138.  * Erase to end of line.
  139.  */
  140. tteeol()
  141. {
  142.     ttputc(ESC);
  143.     ttputc('[');
  144.     ttputc('K');
  145. }
  146.  
  147. /*
  148.  * Erase to end of page.
  149.  */
  150. tteeop()
  151. {
  152.     ttputc(ESC);
  153.     ttputc('[');
  154.     ttputc('J');
  155. }
  156.  
  157. /*
  158.  * Make a noise.
  159.  */
  160. ttbeep()
  161. {
  162.     ttputc(BEL);
  163.     ttflush();
  164. }
  165.  
  166. /*
  167.  * Convert a number to decimal
  168.  * ascii, and write it out. Used to
  169.  * deal with numeric arguments.
  170.  */
  171. asciiparm(n)
  172. register int    n;
  173. {
  174.     register int    q;
  175.  
  176.     q = n/10;
  177.     if (q != 0)
  178.         asciiparm(q);
  179.     ttputc((n%10) + '0');
  180. }
  181.  
  182. /*
  183.  * Insert a block of blank lines onto the
  184.  * screen, using a scrolling region that starts at row
  185.  * "row" and extends down to row "bot". Deal with the one
  186.  * line case, which is a little bit special, with special
  187.  * case code. Put all of the back index commands out
  188.  * in a block. The SCALDstation loses the position
  189.  * of the cursor.
  190.  */
  191. ttinsl(row, bot, nchunk)
  192. {
  193.     if (row == bot) {            /* Funny case.        */
  194.         if (nchunk != 1)
  195.             abort();
  196.         ttmove(row, 0);
  197.         tteeol();
  198.     } else {                /* General case.    */
  199.         ttwindow(row, bot);
  200.         ttmove(row, 0);
  201.         while (nchunk--) {
  202.             ttputc(ESC);        /* Back index.        */
  203.             ttputc('M');
  204.         }
  205. #if    SCALD
  206.         ttrow = HUGE;
  207.         ttcol = HUGE;
  208. #endif
  209.     }
  210. }
  211.  
  212. /*
  213.  * Delete a block of lines, with the uppermost
  214.  * line at row "row", in a screen slice that extends to
  215.  * row "bot". The "nchunk" is the number of lines that have
  216.  * to be deleted. Watch for the pathalogical 1 line case,
  217.  * where the scroll region is *not* the way to do it.
  218.  * The block delete is used by the slightly more
  219.  * optimal display code.
  220.  */
  221. ttdell(row, bot, nchunk)
  222. {
  223.     if (row == bot) {            /* Funny case.        */
  224.         if (nchunk != 1)
  225.             abort();
  226.         ttmove(row, 0);
  227.         tteeol();
  228.     } else {                /* General case.    */
  229.         ttwindow(row, bot);
  230.         ttmove(bot, 0);
  231.         while (nchunk--)
  232.             ttputc(LF);
  233. #if    SCALD
  234.         ttrow = HUGE;
  235.         ttcol = HUGE;
  236. #endif
  237.     }
  238. }
  239.  
  240. /*
  241.  * This routine sets the scrolling window
  242.  * on the display to go from line "top" to line
  243.  * "bot" (origin 0, inclusive). The caller checks
  244.  * for the pathalogical 1 line scroll window that
  245.  * doesn't work right, and avoids it. The "ttrow"
  246.  * and "ttcol" variables are set to a crazy value
  247.  * to ensure that the next call to "ttmove" does
  248.  * not turn into a no-op (the window adjustment
  249.  * moves the cursor).
  250.  */
  251. ttwindow(top, bot)
  252. {
  253.     if (tttop!=top || ttbot!=bot) {
  254.         ttputc(ESC);
  255.         ttputc('[');
  256.         asciiparm(top+1);
  257.         ttputc(';');
  258.         asciiparm(bot+1);
  259.         ttputc('r');
  260.         ttrow = HUGE;            /* Unknown.        */
  261.         ttcol = HUGE;
  262.         tttop = top;            /* Remember region.    */
  263.         ttbot = bot;
  264.     }
  265. }
  266.  
  267. /*
  268.  * Switch to full screen scroll. This is
  269.  * used by "spawn.c" just before is suspends the
  270.  * editor, and by "display.c" when it is getting ready
  271.  * to exit. This function gets to full screen scroll
  272.  * by sending a DECSTBM with default parameters, but
  273.  * I think that this is wrong. The SRM seems to say
  274.  * that the default for Pb is 24, not the size of the
  275.  * screen, which seems really dumb. Do I really have
  276.  * to read the size of the screen as in "ttresize"
  277.  * to do this right?
  278.  */
  279. ttnowindow()
  280. {
  281.     ttputc(ESC);
  282.     ttputc('[');
  283.     ttputc(';');
  284.     ttputc('r');
  285.     ttrow = HUGE;                /* Unknown.        */
  286.     ttcol = HUGE;
  287.     tttop = HUGE;                /* No scroll region.    */
  288.     ttbot = HUGE;
  289. }
  290.  
  291. /*
  292.  * Set the current writing color to the
  293.  * specified color. Watch for color changes that are
  294.  * not going to do anything (the color is already right)
  295.  * and don't send anything to the display.
  296.  * The rainbow version does this in putline.s on a
  297.  * line by line basis, so don't bother sending
  298.  * out the color shift.
  299.  */
  300. ttcolor(color)
  301. register int    color;
  302. {
  303.     if (color != tthue) {
  304. /*
  305. if    !RAINBOW
  306. */
  307.         if (color == CTEXT) {        /* Normal video.    */
  308.             ttputc(ESC);
  309.             ttputc('[');
  310.             ttputc('m');
  311.         } else if (color == CMODE) {    /* Reverse video.    */
  312.             ttputc(ESC);
  313.             ttputc('[');
  314.             ttputc('7');
  315.             ttputc('m');
  316.         }
  317. /*
  318. endif
  319. */
  320.         tthue = color;            /* Save the color.    */
  321.     }
  322. }
  323.  
  324. /*
  325.  * This routine is called by the
  326.  * "refresh the screen" command to try and resize
  327.  * the display. The new size, which must be deadstopped
  328.  * to not exceed the NROW and NCOL limits, it stored
  329.  * back into "nrow" and "ncol". Display can always deal
  330.  * with a screen NROW by NCOL. Look in "window.c" to
  331.  * see how the caller deals with a change.
  332.  */
  333. ttresize()
  334. {
  335.     register int    c;
  336.     register int    newnrow;
  337.     register int    newncol;
  338.  
  339.     ttputc(ESC);                /* Off the end of the    */
  340.     ttputc('[');                /* world. The terminal    */
  341.     asciiparm(HUGE);            /* will chop it.    */
  342.     ttputc(';');
  343.     asciiparm(HUGE);
  344.     ttputc('H');
  345.     ttrow = HUGE;                /* Unknown.        */
  346.     ttcol = HUGE;
  347.     ttputc(ESC);                /* Report position.    */
  348.     ttputc('[');
  349.     ttputc('6');
  350.     ttputc('n');
  351.     ttflush();
  352.     if (ttgetc()!=ESC || ttgetc()!='[')
  353.         return;
  354.     newnrow = 0;
  355.     while ((c=ttgetc())>='0' && c<='9')
  356.         newnrow = 10*newnrow + c - '0';
  357.     if (c != ';')
  358.         return;
  359.     newncol = 0;
  360.     while ((c=ttgetc())>='0' && c<='9')
  361.         newncol = 10*newncol + c - '0';
  362.     if (c != 'R')
  363.         return;
  364.     if (newnrow < 1)            /* Check limits.    */
  365.         newnrow = 1;
  366.     else if (newnrow > NROW)
  367.         newnrow = NROW;
  368.     if (newncol < 1)
  369.         newncol = 1;
  370.     else if (newncol > NCOL)
  371.         newncol = NCOL;
  372.     nrow = newnrow;
  373.     ncol = newncol;
  374. }
  375. SHAR_EOF
  376. if test 7315 -ne "`wc -c < 'tty/ansi/tty.c'`"
  377. then
  378.     echo shar: error transmitting "'tty/ansi/tty.c'" '(should have been 7315 characters)'
  379. fi
  380. fi
  381. echo shar: extracting "'tty/ansi/ttydef.h'" '(1285 characters)'
  382. if test -f 'tty/ansi/ttydef.h'
  383. then
  384.     echo shar: will not over-write existing file "'tty/ansi/ttydef.h'"
  385. else
  386. cat << \SHAR_EOF > 'tty/ansi/ttydef.h'
  387. /*
  388.  * Name:    MicroEMACS
  389.  *        Digital ANSI terminal header file
  390.  * Version:    29
  391.  * Last edit:    05-Feb-86
  392.  * By:        rex::conroy
  393.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  394.  */
  395. #define    GOSLING    1            /* Compile in fancy display.    */
  396. #define    MEMMAP    0            /* Not memory mapped video.    */
  397.  
  398. /*
  399.  * Yes Bob, it's wrong for you.
  400.  */
  401. #define    NROW    66            /* Rows.            */
  402. #define    NCOL    132            /* Columns.            */
  403.  
  404. /*
  405.  * Special keys, as on the LK201, which is
  406.  * a superset of the VT100. Originally I tried to keep the
  407.  * numbers in LK201 escape sequence code, but it became too much
  408.  * of a pain because of the keycodes greater than 31. 
  409.  * The codes are all just redefinitions for the standard extra
  410.  * key codes. Using the standard names ensures that the
  411.  * LK201 codes land in the right place.
  412.  */
  413. #define    KUP    K01
  414. #define    KDOWN    K02
  415. #define    KLEFT    K03
  416. #define    KRIGHT    K04
  417. #define    KFIND    K05
  418. #define    KINSERT    K06
  419. #define    KREMOVE    K07
  420. #define    KSELECT    K08
  421. #define    KPREV    K09
  422. #define    KNEXT    K0A
  423. #define    KF4    K0B
  424. #define    KF6    K0C
  425. #define    KF7    K0D
  426. #define    KF8    K0E
  427. #define    KF9    K0F
  428. #define    KF10    K10
  429. #define    KF11    K11
  430. #define    KF12    K12
  431. #define    KF13    K13
  432. #define    KF14    K14
  433. #define    KHELP    K15
  434. #define    KDO    K16
  435. #define    KF17    K17
  436. #define    KF18    K18
  437. #define    KF19    K19
  438. #define    KF20    K1A
  439. #define    KPF1    K1B
  440. #define    KPF2    K1C
  441. #define    KPF3    K1D
  442. #define    KPF4    K1E
  443. SHAR_EOF
  444. if test 1285 -ne "`wc -c < 'tty/ansi/ttydef.h'`"
  445. then
  446.     echo shar: error transmitting "'tty/ansi/ttydef.h'" '(should have been 1285 characters)'
  447. fi
  448. fi
  449. echo shar: extracting "'tty/ansi/ttykbd.c'" '(4152 characters)'
  450. if test -f 'tty/ansi/ttykbd.c'
  451. then
  452.     echo shar: will not over-write existing file "'tty/ansi/ttykbd.c'"
  453. else
  454. cat << \SHAR_EOF > 'tty/ansi/ttykbd.c'
  455. /*
  456.  * Name:    MicroEMACS
  457.  *         Digital ANSI terminal keyboard.
  458.  *        Assumes LK201, which is OK on the VT100.
  459.  * Version:    29
  460.  * Last edit:    05-Feb-86
  461.  * By:        rex::conroy
  462.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  463.  */
  464. #include    "def.h"
  465.  
  466. #define    ESC    0x1B            /* Escape, arrows et al.    */
  467. #define    AGRAVE    0x60            /* LK201 kludge.        */
  468.  
  469. /*
  470.  * The special keys on an LK201 send back
  471.  * escape sequences of the general form <ESC>[nnn~, where
  472.  * nnn is a key code number. This table is indexed by the
  473.  * nnn code to get the key code, which is used in the
  474.  * binding table. The F4 key, and the F6 through F14 keys
  475.  * have key codes. Also F17 through F20. Think of
  476.  * help and do as special.
  477.  */
  478. short    lk201map[] = {
  479.     KRANDOM,    KFIND,        KINSERT,    KREMOVE,
  480.     KSELECT,    KPREV,        KNEXT,        KRANDOM,
  481.     KRANDOM,    KRANDOM,    KRANDOM,    KRANDOM,
  482.     KRANDOM,    KRANDOM,    KF4,        KRANDOM,
  483.     KRANDOM,    KF6,        KF7,        KF8,
  484.     KF9,        KF10,        KRANDOM,    KF11,
  485.     KF12,        KF13,        KF14,        KRANDOM,
  486.     KHELP,        KDO,        KRANDOM,    KF17,
  487.     KF18,        KF19,        KF20
  488. };
  489.  
  490. /*
  491.  * Names for the keys with basic keycode
  492.  * between KFIRST and KLAST (inclusive). This is used by
  493.  * the key name routine in "kbd.c".
  494.  */
  495. char    *keystrings[] = {
  496.     NULL,        "Up",        "Down",        "Left",
  497.     "Right",    "Find",        "Insert",    "Remove",
  498.     "Select",    "Previous",    "Next",        "F4",
  499.     "F6",        "F7",        "F8",        "F9",
  500.     "F10",        "F11",        "F12",        "F13",
  501.     "F14",        "Help",        "Do",        "F17",
  502.     "F18",        "F19",        "F20",        "PF1",
  503.     "PF2",        "PF3",        "PF4",        NULL
  504. };
  505.  
  506. /*
  507.  * Read in a key, doing the low level mapping
  508.  * of ASCII code to 11 bit code. This level deals with
  509.  * mapping the special keys into their spots in the C1
  510.  * control area. The C0 controls go right through, and
  511.  * get remapped by "getkey".
  512.  */
  513. getkbd()
  514. {
  515.     register int    c;
  516.     register int    n;
  517. loop:
  518.     c = ttgetc();
  519.     if (c == AGRAVE)            /* On LK201, grave is    */
  520.         c = METACH;            /* also META.        */
  521.     if (c == ESC) {
  522.         c = ttgetc();
  523.         if (c == '[') {
  524.             c = ttgetc();
  525.             if (c == 'A')
  526.                 return (KUP);
  527.             if (c == 'B')
  528.                 return (KDOWN);
  529.             if (c == 'C')
  530.                 return (KRIGHT);
  531.             if (c == 'D')
  532.                 return (KLEFT);
  533.             if (c>='0' && c<='9') {    /* LK201 functions.    */
  534.                 n = 0;
  535.                 do {
  536.                     n = 10*n + c - '0';
  537.                     c = ttgetc();
  538.                 } while (c>='0' && c<='9');
  539.                 if (c=='~' && n<=34) {
  540.                     c = lk201map[n];
  541.                     if (c != KRANDOM)
  542.                         return (c);
  543.                     goto loop;
  544.                 }
  545.             }
  546.             goto loop;
  547.         }
  548.         if (c == 'O') {    
  549.             c = ttgetc();
  550.             if (c == 'A')
  551.                 return (KUP);
  552.             if (c == 'B')
  553.                 return (KDOWN);
  554.             if (c == 'C')
  555.                 return (KRIGHT);
  556.             if (c == 'D')
  557.                 return (KLEFT);
  558.             if (c == 'P')
  559.                 return (KPF1);
  560.             if (c == 'Q')
  561.                 return (KPF2);
  562.             if (c == 'R')
  563.                 return (KPF3);
  564.             if (c == 'S')
  565.                 return (KPF4);
  566.             goto loop;
  567.         }
  568.         if (ISLOWER(c) != FALSE)    /* Copy the standard    */
  569.             c = TOUPPER(c);        /* META code.        */
  570.         if (c>=0x00 && c<=0x1F)
  571.             c = KCTRL | (c+'@');
  572.         return (KMETA | c);
  573.     }
  574.     return (c);
  575. }
  576.  
  577. /*
  578.  * Terminal specific keymap initialization.
  579.  * Attach the special keys to the appropriate built
  580.  * in functions. Bind all of the assigned graphics in the
  581.  * DEC supplimental character set to "ins-self".
  582.  * As is the case of all the keymap routines, errors
  583.  * are very fatal.
  584.  */
  585. ttykeymapinit()
  586. {
  587.     register SYMBOL    *sp;
  588.     register int    i;
  589.  
  590.     keydup(KFIND,    "search-again");
  591.     keydup(KHELP,    "help");
  592.     keydup(KINSERT, "yank");
  593.     keydup(KREMOVE, "kill-region");
  594.     keydup(KSELECT, "set-mark");
  595.     keydup(KPREV,    "back-page");
  596.     keydup(KNEXT,    "forw-page");
  597.     keydup(KDO,    "execute-macro");
  598.     keydup(KF17,    "back-window");
  599.     keydup(KF18,    "forw-window");
  600.     keydup(KF19,    "enlarge-window");
  601.     keydup(KF20,    "shrink-window");
  602.     keydup(KUP,    "back-line");
  603.     keydup(KDOWN,    "forw-line");
  604.     keydup(KRIGHT,    "forw-char");
  605.     keydup(KLEFT,    "back-char");
  606.  
  607.     /*
  608.      * Bind all GR positions that correspond
  609.      * to assigned characters in the Digital multinational
  610.      * character set to "ins-self". These characters may
  611.      * be used just like any other character.
  612.      */
  613.  
  614.     if ((sp=symlookup("ins-self")) == NULL)
  615.         abort();
  616.     for (i=0xA0; i<0xFF; ++i) {
  617.         if (i!=0xA4 && i!=0xA6 && i!=0xAC && i!=0xAD && i!=0xAE
  618.         &&  i!=0xAF && i!=0xB4 && i!=0xB8 && i!=0xBE && i!=0xF0
  619.         &&  i!=0xFE && i!=0xA0) {
  620.             if (binding[i] != NULL)
  621.                 abort();
  622.             binding[i] = sp;
  623.             ++sp->s_nkey;
  624.         }
  625.     }
  626. }
  627. SHAR_EOF
  628. if test 4152 -ne "`wc -c < 'tty/ansi/ttykbd.c'`"
  629. then
  630.     echo shar: error transmitting "'tty/ansi/ttykbd.c'" '(should have been 4152 characters)'
  631. fi
  632. fi
  633. echo shar: done with directory "'tty/ansi'"
  634. if test ! -d 'tty/atari'
  635. then
  636.     echo shar: creating directory "'tty/atari'"
  637.     mkdir 'tty/atari'
  638. fi
  639. echo shar: extracting "'tty/atari/tty.c'" '(2927 characters)'
  640. if test -f 'tty/atari/tty.c'
  641. then
  642.     echo shar: will not over-write existing file "'tty/atari/tty.c'"
  643. else
  644. cat << \SHAR_EOF > 'tty/atari/tty.c'
  645. /*
  646.  * Name:    MicroEMACS
  647.  *        Atari 520ST terminal.
  648.  * Version:    30
  649.  * Last edit:    22-Feb-86
  650.  * By:        rex::conroy
  651.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  652.  *
  653.  * This code simulates scrolling regions by using the
  654.  * insert line and delete line functions. Should display
  655.  * handling be taught about this. Based on Rich's code
  656.  * for the Heath H19.
  657.  */
  658. #include    "def.h"
  659.  
  660. #define    BEL    0x07            /* BEL character.        */
  661. #define    ESC    0x1B            /* ESC character.        */
  662. #define    LF    0x0A            /* Line feed.            */
  663.  
  664. extern    int    ttrow;
  665. extern    int    ttcol;
  666. extern    int    tttop;
  667. extern    int    ttbot;
  668. extern    int    tthue;
  669.  
  670. int    tceeol    =    2;        /* Costs.            */
  671. int    tcinsl    =    11;
  672. int    tcdell    =    11;
  673.  
  674. /*
  675.  * No-op.
  676.  */
  677. ttinit()
  678. {
  679. }
  680.  
  681. /*
  682.  * No-op.
  683.  */
  684. tttidy()
  685. {
  686. }
  687.  
  688. /*
  689.  * Move the cursor to the specified
  690.  * origin 0 row and column position. Try to
  691.  * optimize out extra moves; redisplay may
  692.  * have left the cursor in the right location
  693.  * on the screen last time.
  694.  */
  695. ttmove(row, col)
  696. {
  697.     if (ttrow!=row || ttcol!=col) {
  698.         if (row > nrow)
  699.             row = nrow;
  700.         if (col > ncol)
  701.             col = ncol;
  702.         ttputc(ESC);
  703.         ttputc('Y');
  704.         ttputc(row+' ');
  705.         ttputc(col+' ');
  706.         ttrow = row;
  707.         ttcol = col;
  708.     }
  709. }
  710.  
  711. /*
  712.  * Erase to end of line.
  713.  */
  714. tteeol()
  715. {
  716.     ttputc(ESC);
  717.     ttputc('K');
  718. }
  719.  
  720. /*
  721.  * Erase to end of page.
  722.  */
  723. tteeop()
  724. {
  725.     ttputc(ESC);
  726.     ttputc('J');
  727. }
  728.  
  729. /*
  730.  * Make a noise.
  731.  */
  732. ttbeep()
  733. {
  734.     ttputc(BEL);
  735.     ttflush();
  736. }
  737.  
  738. /*
  739.  * Insert nchunk blank line(s) onto the
  740.  * screen, scrolling the last line on the
  741.  * screen off the bottom. This is done with
  742.  * a cluster of clever insert and delete commands,
  743.  * because there are no scroll regions.
  744.  */
  745. ttinsl(row, bot, nchunk)
  746. {
  747.     register int    i;
  748.  
  749.     if (row == bot) {
  750.         ttmove(row, 0);
  751.         tteeol();
  752.         return;
  753.     }
  754.     ttmove(1+bot-nchunk, 0);
  755.     for (i=0; i<nchunk; i++) {
  756.         ttputc(ESC);
  757.         ttputc('M');
  758.     }
  759.     ttmove(row, 0);
  760.     for (i=0; i<nchunk; i++) {
  761.         ttputc(ESC);
  762.         ttputc('L');
  763.     }
  764.     ttrow = row;
  765.     ttcol = 0;
  766. }
  767.  
  768. /*
  769.  * Delete nchunk line(s) "row", replacing the
  770.  * bottom line on the screen with a blank
  771.  * line. This is done with a crafty sequences
  772.  * of insert and delete line; there is no scroll
  773.  * region on the Heath. The presence of the
  774.  * echo area makes a boundry condition
  775.  * go away.
  776.  */
  777. ttdell(row, bot, nchunk)
  778. {
  779.     register int    i;
  780.  
  781.     if (row == bot) {
  782.         ttmove(row, 0);
  783.         tteeol();
  784.         return;
  785.     }
  786.     ttmove(row, 0);
  787.     for (i=0; i<nchunk; i++) {
  788.         ttputc(ESC);
  789.         ttputc('M');
  790.     }
  791.     ttmove(1+bot-nchunk,0);
  792.     for (i=0; i<nchunk; i++) {
  793.         ttputc(ESC);
  794.         ttputc('L');
  795.     }
  796.     ttrow = bot-nchunk;
  797.     ttcol = 0;
  798. }
  799.  
  800. /*
  801.  * No-op.
  802.  */
  803. ttwindow(top, bot)
  804. {
  805. }
  806.  
  807. /*
  808.  * No-op.
  809.  */
  810. ttnowindow()
  811. {
  812. }
  813.  
  814. /*
  815.  * Set display color on Heath. Normal
  816.  * video is text color. Reverse video is used for
  817.  * the mode line.
  818.  */
  819. ttcolor(color)
  820. register int    color;
  821. {
  822.     if (color != tthue) {
  823.         if (color == CTEXT) {        /* Normal video.    */
  824.             ttputc(ESC);
  825.             ttputc('q');
  826.         } else if (color == CMODE) {    /* Reverse video.    */
  827.             ttputc(ESC);
  828.             ttputc('p');
  829.         }
  830.         tthue = color;
  831.     }
  832. }
  833.  
  834. /*
  835.  * No-op.
  836.  */
  837. ttresize()
  838. {
  839. }
  840. SHAR_EOF
  841. if test 2927 -ne "`wc -c < 'tty/atari/tty.c'`"
  842. then
  843.     echo shar: error transmitting "'tty/atari/tty.c'" '(should have been 2927 characters)'
  844. fi
  845. fi
  846. echo shar: extracting "'tty/atari/ttydef.h'" '(691 characters)'
  847. if test -f 'tty/atari/ttydef.h'
  848. then
  849.     echo shar: will not over-write existing file "'tty/atari/ttydef.h'"
  850. else
  851. cat << \SHAR_EOF > 'tty/atari/ttydef.h'
  852. /*
  853.  * Name:    MicroEMACS
  854.  *        Atari 520ST header file.
  855.  * Version:    30
  856.  * Last edit:    22-Feb-86
  857.  * By:        rex::conroy
  858.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  859.  */
  860. #define    GOSLING    1            /* Use fancy redisplay.        */
  861. #define    MEMMAP    0            /* Not memory mapped video.    */
  862.  
  863. #define    NROW    50            /* The "50" is big enough to    */
  864. #define    NCOL    80            /* deal with the "hi50" screen.    */
  865.  
  866. /*
  867.  * Special keys.
  868.  */
  869. #define    KF1    K01
  870. #define    KF2    K02
  871. #define    KF3    K03
  872. #define    KF4    K04
  873. #define    KF5    K05
  874. #define    KF6    K06
  875. #define    KF7    K07
  876. #define    KF8    K08
  877. #define    KF9    K09
  878. #define    KF10    K0A
  879. #define    KHELP    K0B
  880. #define    KUNDO    K0C
  881. #define    KINSERT    K0D
  882. #define    KUP    K0E
  883. #define    KCLEAR    K0F
  884. #define    KLEFT    K10
  885. #define    KDOWN    K11
  886. #define    KRIGHT    K12
  887. SHAR_EOF
  888. if test 691 -ne "`wc -c < 'tty/atari/ttydef.h'`"
  889. then
  890.     echo shar: error transmitting "'tty/atari/ttydef.h'" '(should have been 691 characters)'
  891. fi
  892. fi
  893. echo shar: extracting "'tty/atari/ttykbd.c'" '(2018 characters)'
  894. if test -f 'tty/atari/ttykbd.c'
  895. then
  896.     echo shar: will not over-write existing file "'tty/atari/ttykbd.c'"
  897. else
  898. cat << \SHAR_EOF > 'tty/atari/ttykbd.c'
  899. /*
  900.  * Name:    MicroEMACS
  901.  *        Atari 520ST keyboard.
  902.  * Version:    30
  903.  * Last edit:    22-Feb-86
  904.  * By:        rex::conroy
  905.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  906.  */
  907. #include    "def.h"
  908. #include    <osbind.h>
  909.  
  910. /*
  911.  * Key names.
  912.  */
  913. char    *keystrings[] = {
  914.     NULL,        "F1",        "F2",        "F3",
  915.     "F4",        "F5",        "F6",        "F7",
  916.     "F8",        "F9",        "F10",        "Help",
  917.     "Undo",        "Insert",    "Up",        "Clr/Home",
  918.     "Left",        "Down",        "Right",    NULL,
  919.     NULL,        NULL,        NULL,        NULL,
  920.     NULL,        NULL,        NULL,        NULL,
  921.     NULL,        NULL,        NULL,        NULL
  922. };
  923.  
  924. /*
  925.  * This function is used to read the
  926.  * keyboard for the first time. A call to the system
  927.  * is made directly, to see the 32 bit key code. If the
  928.  * scan code says this is a function key, remap the
  929.  * codes. I might want to make the "Alt" key work like
  930.  * a "Meta" key, by looking at scan code.
  931.  */
  932. getkbd()
  933. {
  934.     register long    rawkey;
  935.     register int    k;
  936.  
  937.     rawkey = Crawcin();
  938.     k = (rawkey>>16) & 0xFF;        /* Scan code.        */
  939.     if (k == 0x3B)
  940.         return (KF1);
  941.     if (k == 0x3C)
  942.         return (KF2);
  943.     if (k == 0x3D)
  944.         return (KF3);
  945.     if (k == 0x3E)
  946.         return (KF4);
  947.     if (k == 0x3F)
  948.         return (KF5);
  949.     if (k == 0x40)
  950.         return (KF6);
  951.     if (k == 0x41)
  952.         return (KF7);
  953.     if (k == 0x42)
  954.         return (KF8);
  955.     if (k == 0x43)
  956.         return (KF9);
  957.     if (k == 0x44)
  958.         return (KF10);
  959.     if (k == 0x62)
  960.         return (KHELP);
  961.     if (k == 0x61)
  962.         return (KUNDO);
  963.     if (k == 0x52)
  964.         return (KINSERT);
  965.     if (k == 0x48)
  966.         return (KUP);
  967.     if (k == 0x47)
  968.         return (KCLEAR);
  969.     if (k == 0x4B)
  970.         return (KLEFT);
  971.     if (k == 0x50)
  972.         return (KDOWN);
  973.     if (k == 0x4D)
  974.         return (KRIGHT);
  975.     return ((int)(rawkey&0x7F));
  976. }
  977.  
  978. /*
  979.  * Establish default keypad
  980.  * bindings. The "Undo" key is bound to the
  981.  * "execute-macro"; this is where I bind "Do" on
  982.  * an LK201, and it is very handy.
  983.  * All of the Fn keys are bindable, but there
  984.  * are no default bindings.
  985.  */
  986. ttykeymapinit()
  987. {
  988.     keydup(KHELP,    "help");
  989.     keydup(KUNDO,    "execute-macro");
  990.     keydup(KINSERT,    "yank");
  991.     keydup(KUP,    "back-line");
  992.     keydup(KCLEAR,    "kill-region");
  993.     keydup(KLEFT,    "back-char");
  994.     keydup(KDOWN,    "forw-line");
  995.     keydup(KRIGHT,    "forw-char");
  996. }
  997. SHAR_EOF
  998. if test 2018 -ne "`wc -c < 'tty/atari/ttykbd.c'`"
  999. then
  1000.     echo shar: error transmitting "'tty/atari/ttykbd.c'" '(should have been 2018 characters)'
  1001. fi
  1002. fi
  1003. echo shar: done with directory "'tty/atari'"
  1004. if test ! -d 'tty/heath'
  1005. then
  1006.     echo shar: creating directory "'tty/heath'"
  1007.     mkdir 'tty/heath'
  1008. fi
  1009. echo shar: extracting "'tty/heath/tty.c'" '(3530 characters)'
  1010. if test -f 'tty/heath/tty.c'
  1011. then
  1012.     echo shar: will not over-write existing file "'tty/heath/tty.c'"
  1013. else
  1014. cat << \SHAR_EOF > 'tty/heath/tty.c'
  1015. /*
  1016.  * Name:    MicroEMACS
  1017.  *        Heath H19 display
  1018.  * Version:    29
  1019.  * Last edit:    10-Feb-86
  1020.  * By:        rex::conroy
  1021.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  1022.  *
  1023.  * This code simulates scrolling regions by using the
  1024.  * insert line and delete line functions. Should display
  1025.  * handling be told about this?
  1026.  * This is code is by Rich Ellison. A man always does
  1027.  * the support for the terminal he owns.
  1028.  */
  1029. #include    "def.h"
  1030.  
  1031. #define    BEL    0x07            /* BEL character.        */
  1032. #define    ESC    0x1B            /* ESC character.        */
  1033. #define    LF    0x0A            /* Line feed.            */
  1034.  
  1035. extern    int    ttrow;
  1036. extern    int    ttcol;
  1037. extern    int    tttop;
  1038. extern    int    ttbot;
  1039. extern    int    tthue;
  1040.  
  1041. int    tceeol    =    2;        /* Costs.            */
  1042. int    tcinsl    =    11;
  1043. int    tcdell    =    11;
  1044.  
  1045. /*
  1046.  * The Heath needs no initialization.
  1047.  */
  1048. ttinit()
  1049. {
  1050. }
  1051.  
  1052. /*
  1053.  * The Heath needs no tidy up.
  1054.  */
  1055. tttidy()
  1056. {
  1057. }
  1058.  
  1059. /*
  1060.  * Move the cursor to the specified
  1061.  * origin 0 row and column position. Try to
  1062.  * optimize out extra moves; redisplay may
  1063.  * have left the cursor in the right
  1064.  * location last time!
  1065.  */
  1066. ttmove(row, col)
  1067. {
  1068.     if (ttrow!=row || ttcol!=col) {
  1069.         if (row > NROW)
  1070.             row = NROW;
  1071.         if (col > NCOL)
  1072.             col = NCOL;
  1073.         ttputc(ESC);
  1074.         ttputc('Y');
  1075.         ttputc(row+' ');
  1076.         ttputc(col+' ');
  1077.         ttrow = row;
  1078.         ttcol = col;
  1079.     }
  1080. }
  1081.  
  1082. /*
  1083.  * Erase to end of line.
  1084.  */
  1085. tteeol()
  1086. {
  1087.     ttputc(ESC);
  1088.     ttputc('K');
  1089. }
  1090.  
  1091. /*
  1092.  * Erase to end of page.
  1093.  */
  1094. tteeop()
  1095. {
  1096.     ttputc(ESC);
  1097.     ttputc('J');
  1098. }
  1099.  
  1100. /*
  1101.  * Make a noise.
  1102.  */
  1103. ttbeep()
  1104. {
  1105.     ttputc(BEL);
  1106.     ttflush();
  1107. }
  1108.  
  1109. /*
  1110.  * Insert nchunk blank line(s) onto the
  1111.  * screen, scrolling the last line on the
  1112.  * screen off the bottom. This is done with
  1113.  * a cluster of clever insert and delete commands,
  1114.  * because there are no scroll regions.
  1115.  */
  1116. ttinsl(row, bot, nchunk)
  1117. {
  1118.     register int    i;
  1119.  
  1120.     if (row == bot) {        /* Case of one line insert is     */
  1121.         ttmove(row, 0);        /*    special            */
  1122.         tteeol();
  1123.         return;
  1124.     }
  1125.     ttmove(1+bot-nchunk, 0);
  1126.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  1127.         ttputc(ESC);        /* DEL current line, anything    */
  1128.         ttputc('M');        /* below moves up.        */
  1129.     }
  1130.     ttmove(row, 0);
  1131.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  1132.         ttputc(ESC);        /* INS before current line,    */
  1133.         ttputc('L');        /* sliding stuff down.        */
  1134.     }
  1135.     ttrow = row;            /* End up on current line    */
  1136.     ttcol = 0;
  1137. }
  1138.  
  1139. /*
  1140.  * Delete nchunk line(s) "row", replacing the
  1141.  * bottom line on the screen with a blank
  1142.  * line. This is done with a crafty sequences
  1143.  * of insert and delete line; there is no scroll
  1144.  * region on the Heath. The presence of the
  1145.  * echo area makes a boundry condition
  1146.  * go away.
  1147.  */
  1148. ttdell(row, bot, nchunk)
  1149. {
  1150.     register int    i;
  1151.  
  1152.     if (row == bot) {        /* One line special case    */
  1153.         ttmove(row, 0);
  1154.         tteeol();
  1155.         return;
  1156.     }
  1157.     ttmove(row, 0);
  1158.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  1159.         ttputc(ESC);        /* DEL top line, lines below    */
  1160.         ttputc('M');        /* all move up.            */
  1161.     }
  1162.     ttmove(1+bot-nchunk,0);
  1163.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  1164.         ttputc(ESC);        /* INS line before botton,    */ 
  1165.         ttputc('L');        /* all lines move down.        */ 
  1166.     }
  1167.     ttrow = bot-nchunk;
  1168.     ttcol = 0;
  1169. }
  1170.  
  1171. /*
  1172.  * No-op.
  1173.  */
  1174. ttwindow(top, bot)
  1175. {
  1176. }
  1177.  
  1178. /*
  1179.  * No-op.
  1180.  */
  1181. ttnowindow()
  1182. {
  1183. }
  1184.  
  1185. /*
  1186.  * Set display color on Heath. Normal
  1187.  * video is text color. Reverse video is used for
  1188.  * the mode line. Rich knew the sequences for the
  1189.  * Heath by heart.
  1190.  */
  1191. ttcolor(color)
  1192. register int    color;
  1193. {
  1194.     if (color != tthue) {
  1195.         if (color == CTEXT) {        /* Normal video.    */
  1196.             ttputc(ESC);
  1197.             ttputc('q');
  1198.         } else if (color == CMODE) {    /* Reverse video.    */
  1199.             ttputc(ESC);
  1200.             ttputc('p');
  1201.         }
  1202.         tthue = color;
  1203.     }
  1204. }
  1205.  
  1206. /*
  1207.  * No-op.
  1208.  */
  1209. ttresize()
  1210. {
  1211. }
  1212. SHAR_EOF
  1213. if test 3530 -ne "`wc -c < 'tty/heath/tty.c'`"
  1214. then
  1215.     echo shar: error transmitting "'tty/heath/tty.c'" '(should have been 3530 characters)'
  1216. fi
  1217. fi
  1218. echo shar: extracting "'tty/heath/ttydef.h'" '(352 characters)'
  1219. if test -f 'tty/heath/ttydef.h'
  1220. then
  1221.     echo shar: will not over-write existing file "'tty/heath/ttydef.h'"
  1222. else
  1223. cat << \SHAR_EOF > 'tty/heath/ttydef.h'
  1224. /*
  1225.  * Name:    MicroEMACS
  1226.  *        Heath H19 header file
  1227.  * Version:    29
  1228.  * Last edit:    05-Feb-86
  1229.  * By:        rex::conroy
  1230.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  1231.  */
  1232. #define    GOSLING    1            /* Use fancy redisplay.        */
  1233. #define    MEMMAP    0            /* Not memory mapped video.    */
  1234.  
  1235. #define    NROW    24            /* Use line 25?    The only H19 I    */
  1236. #define    NCOL    80            /* used had line 25 bugs.    */
  1237. SHAR_EOF
  1238. if test 352 -ne "`wc -c < 'tty/heath/ttydef.h'`"
  1239. then
  1240.     echo shar: error transmitting "'tty/heath/ttydef.h'" '(should have been 352 characters)'
  1241. fi
  1242. fi
  1243. echo shar: extracting "'tty/heath/ttykbd.c'" '(679 characters)'
  1244. if test -f 'tty/heath/ttykbd.c'
  1245. then
  1246.     echo shar: will not over-write existing file "'tty/heath/ttykbd.c'"
  1247. else
  1248. cat << \SHAR_EOF > 'tty/heath/ttykbd.c'
  1249. /*
  1250.  * Name:    MicroEMACS
  1251.  *        Heath H19 keyboard
  1252.  * Version:    29
  1253.  * Last edit:    05-Feb-86
  1254.  * By:        rex::conroy
  1255.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  1256.  */
  1257. #include    "def.h"
  1258.  
  1259. /*
  1260.  * Empty key name table.
  1261.  */
  1262. char    *keystrings[] = {
  1263.     NULL,        NULL,        NULL,        NULL,
  1264.     NULL,        NULL,        NULL,        NULL,
  1265.     NULL,        NULL,        NULL,        NULL,
  1266.     NULL,        NULL,        NULL,        NULL,
  1267.     NULL,        NULL,        NULL,        NULL,
  1268.     NULL,        NULL,        NULL,        NULL,
  1269.     NULL,        NULL,        NULL,        NULL,
  1270.     NULL,        NULL,        NULL,        NULL
  1271. };
  1272.  
  1273. /*
  1274.  * Get keyboard character, and interpret
  1275.  * any special keys on the keyboard. This is really
  1276.  * easy, because there arn't any special keys.
  1277.  */
  1278. getkbd()
  1279. {
  1280.     return (ttgetc());
  1281. }
  1282.  
  1283. /*
  1284.  * No special keys.
  1285.  */
  1286. ttykeymapinit()
  1287. {
  1288. }
  1289. SHAR_EOF
  1290. if test 679 -ne "`wc -c < 'tty/heath/ttykbd.c'`"
  1291. then
  1292.     echo shar: error transmitting "'tty/heath/ttykbd.c'" '(should have been 679 characters)'
  1293. fi
  1294. fi
  1295. echo shar: done with directory "'tty/heath'"
  1296. echo shar: done with directory "'tty'"
  1297. exit 0
  1298. #    End of shell archive
  1299.